package com.bush.mall.member.controller;

import org.springframework.web.bind.annotation.*;
import com.bush.mall.common.entity.Result;;
import com.bush.mall.member.entity.MemberEntity;
import com.bush.mall.member.service.MemberService;
import javax.annotation.Resource;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 会员
 * @author RUN
 * @date 2022-11-29
 */
@RestController
@RequestMapping("member")
@Api(tags = "会员管理" )
public class MemberController {

    @Resource(name= MemberService.BEAN_ID)
    private MemberService memberService;

    /**
     * 分页查询会员列表
     * @author RUN
     * @date 2022-11-29
     */
    @ApiOperation(value = "分页查询会员列表")
    @GetMapping("queryForPage")
    public Result queryForPage(Integer current,Integer size){
        return memberService.queryForPage(current,size);
    }

    /**
     * 保存会员表单
     * @author RUN
     * @date 2022-11-29
     */
    @ApiOperation(value = "保存会员表单")
    @PostMapping
    public Result saveMember(@RequestBody MemberEntity member){
        return memberService.saveMember(member);
    }

    /**
     * 修改会员表单
     * @author RUN
     * @date 2022-11-29
     */
    @ApiOperation(value = "修改会员表单")
    @PutMapping
    public Result updateMember(@RequestBody MemberEntity member){
        return memberService.updateMember(member);
    }

    /**
     * 通过指定id删除会员
     * @author RUN
     * @date 2022-11-29
     */
    @ApiOperation(value = "通过指定id删除会员")
    @DeleteMapping
    public Result deleteMember(Long id){
        return memberService.deleteMember(id);
    }

}
